﻿namespace MDXStudio.QueryEditor
{
    using System;

    public class TextSegment
    {
        private eHighlightType mHighlightType;
        private int mLenth;
        private int mStartPosition;

        public TextSegment(eHighlightType pHighlightType, int pStartPosition, int pLength)
        {
            this.mHighlightType = pHighlightType;
            this.mStartPosition = pStartPosition;
            this.mLenth = pLength;
        }

        public override bool Equals(object pObj)
        {
            if (pObj is TextSegment)
            {
                TextSegment segment = (TextSegment) pObj;
                if (((this.mStartPosition == segment.mStartPosition) && (this.mLenth == segment.mLenth)) && (this.mHighlightType == segment.mHighlightType))
                {
                    return true;
                }
            }
            return false;
        }

        public override int GetHashCode()
        {
            return this.mStartPosition;
        }

        public bool StartIsIn(TextSegment pTextSegment)
        {
            bool flag = false;
            if (((this.mStartPosition - pTextSegment.StartPosition) > 0) & ((this.mStartPosition - pTextSegment.StartPosition) < pTextSegment.Lenth))
            {
                flag = true;
            }
            return flag;
        }

        public eHighlightType HighlightType
        {
            get
            {
                return this.mHighlightType;
            }
            set
            {
                this.mHighlightType = value;
            }
        }

        public int Lenth
        {
            get
            {
                return this.mLenth;
            }
            set
            {
                this.mLenth = value;
            }
        }

        public int StartPosition
        {
            get
            {
                return this.mStartPosition;
            }
            set
            {
                this.mStartPosition = value;
            }
        }
    }
}

